﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CourseList.aspx.cs" Inherits="TrainingWorkshop.Presentation.CourseList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Course</title>
</head>
<body>
    <form id="CourseListForm" runat="server">
    <div>
        <%--//Design the first field 
        //Search course--%>
        <fieldset id="SearchFieldset" runat="server">
            <legend>Search Course</legend>
            <table style="width: 80%;">
                <tr>
                    <td>
                        <asp:Label ID="CourseNameLabel" runat="server" Text="Course Name"></asp:Label>&nbsp;&nbsp;
                        <asp:TextBox ID="CourseNameTextBox" runat="server"></asp:TextBox>
                        <font color="red">*</font>
                        <asp:Label ID="WarningLabel" runat="server"></asp:Label>
                    </td>
                    <td>
                        <asp:Label ID="StatusLabel" runat="server" Text="Course Status"></asp:Label>
                        <asp:RadioButtonList ID="StatusRadioButtonList" runat="server" RepeatDirection="Horizontal"
                            RepeatLayout="Flow">
                            <asp:ListItem Value="True" Selected="true">Open</asp:ListItem>
                            <asp:ListItem Value="False">Closed</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                    <td>
                        <asp:Button ID="SearchButton" runat="server" Text="Search" OnClick="SearchButton_Click" />
                    </td>
                </tr>
            </table>
        </fieldset>
        <%--    //Design the second fieldset
    //Show the selected courses through gridview--%>
        <fieldset id="ListFieldset" runat="server">
            <legend>Course List</legend>
            <table>
                <tr>
                    <td>
                        <asp:Button ID="CreateButton" runat="server" Text="Create New Course" />
                        &nbsp;&nbsp;
                        <asp:Button ID="ChangeStatusButton" runat="server" Text="Batch Close Course" OnClick="ChangeStatusButton_Click" />
                        &nbsp;&nbsp;
                        <asp:CheckBox ID="AllCoursesCheckBox" runat="server" AutoPostBack="True" Text="AllCourses"
                            OnCheckedChanged="AllCoursesCheckBox_CheckedChanged" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:GridView ID="CourseListGridView" runat="server" CellPadding="4" ForeColor="#333333"
                            GridLines="None" PagerStyle-HorizontalAlign="Right" AutoGenerateColumns="False"
                            OnRowEditing="CourseListGridView_RowEditing" OnRowDeleting="CourseListGridView_RowDeleting"
                            OnRowDataBound="CourseListGridView_RowDataBound" OnRowCancelingEdit="CourseListGridView_Cancel"
                            OnRowUpdating="CourseListGridView_Update" AllowPaging="True">
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:CheckBox ID="StatusCheckBox" runat="server" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="CourseId">
                                    <ItemTemplate>
                                        <asp:Label ID="CourseIdLabel" runat="server" Text='<%# Bind("CourseId") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="CourseName">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="CourseNameEditTextBox" runat="server" Text='<%# Bind("CourseName") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="CourseNameEditLabel" runat="server" Text='<%# Bind("CourseName") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Teacher">
                                    <ItemTemplate>
                                        <asp:Label ID="TeacherNameLabel" runat="server" Text='<%# Bind("Teacher.TeacherName") %>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:HiddenField ID="TeacherHiddenField" runat="server" Value='<%# Bind("Teacher.TeacherName") %>' />
                                        <asp:DropDownList ID="TeacherDropDownList" runat="server">
                                        </asp:DropDownList>
                                    </EditItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Course Level">
                                    <ItemTemplate>
                                        <asp:Label ID="LevelLabel" runat="server" Text='<%# Bind("Level.LevelName") %>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:HiddenField ID="LevelHiddenField" runat="server" Value='<%# Bind("level.LevelName") %>' />
                                        <asp:DropDownList ID="LevelDropDownList" runat="server">
                                        </asp:DropDownList>
                                    </EditItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Course Status">
                                    <EditItemTemplate>
                                        <asp:DropDownList ID="StatusDropDownList" runat="server">
                                        </asp:DropDownList>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="StatusLabel" runat="server" Text='<%# Convert.ToBoolean(Eval("CourseStatus"))?"Open":"Closed" %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:CommandField ShowEditButton="true" EditText="Edit" />
                                <asp:TemplateField HeaderText="Actions">
                                    <ItemTemplate>
                                        <%--<asp:Button ID="ButtonEdit" runat="server" Text="Update" CommandName="Edit"></asp:Button>--%>
                                        <asp:Button ID="ButtonDelete" runat="server" Text="Delete" CommandName="Delete">
                                        </asp:Button>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <EditRowStyle BackColor="#999999" />
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <SortedAscendingCellStyle BackColor="#E9E7E2" />
                            <SortedAscendingHeaderStyle BackColor="#506C8C" />
                            <SortedDescendingCellStyle BackColor="#FFFDF8" />
                            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                            <SortedAscendingCellStyle BackColor="#E9E7E2"></SortedAscendingCellStyle>
                            <SortedAscendingHeaderStyle BackColor="#506C8C"></SortedAscendingHeaderStyle>
                            <SortedDescendingCellStyle BackColor="#FFFDF8"></SortedDescendingCellStyle>
                            <SortedDescendingHeaderStyle BackColor="#6F8DAE"></SortedDescendingHeaderStyle>
                        </asp:GridView>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="SelectAllCheckBox" runat="server" Text="SelectAll" OnCheckedChanged="SelectAllCheckBox_CheckedChanged"
                            AutoPostBack="True" />
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
    </form>
</body>
</html>
